package lintcode.NO2411;

import java.time.Period;
import java.util.Calendar;
import java.util.Scanner;

public class TestMain {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String[] split = s.split(" ");
        int n = Integer.parseInt(split[0]);
        int m = Integer.parseInt(split[1]);
        //calendar中month的第一个月是0
        Calendar calendar = Calendar.getInstance();
        calendar.set(n,m-1,1);
        System.out.println(calendar.get(Calendar.YEAR));
        System.out.println(calendar.get(Calendar.MONTH));
        int days = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
        System.out.println(days);

    }
}
